#ifndef __CPIL_EXCEPTION_HPP__
#define __CPIL_EXCEPTION_HPP__

#define EXCEPTION_INFOS __FUNCTION__,__FILE__,__LINE__

//!  The class Exception - manages only user-defined exception
/*!
  This class provides user exceptions. They can be handle (throw) in any files of this project (seamless Editing).
  Please note that the macro EXCEPTION_INFOS is directly linked to this Exception Class definition and makes the call of Exception constructor easier.
  Indeed, the three last Parameters of each Exception constructors could be handled by EXCEPTION_INFOS(const char * function, const char * file, int line);
  Otherwise, Parameter Name is always required and define the name of the exception. The parameter object is not required but can be used to specify some additional informations.
*/

class Exception
{
    protected:

        //! Attribute name(char *);
        /*! This attribute gives the name (the reason) that the exception had been thrown. */
        char * name;

        //! Attribute func(char *);
        /*! This attribute gives the function where the exception had been thrown. */
        char * func;

        //! Attribute file(char *);
        /*! This attribute gives the file where the exception had been thrown. */
        char * file;

        //! Attribute func(int);
        /*! This attribute gives the line where the exception had been thrown. */
        int    line;

        inline virtual void __delete();

    public:


        //! Default constructor;
        /*! This constructor initializes attributes as unknown but can be thrown. */
        Exception();

        //! Default destructor;
        /*! Destructor, cleans and deletes memory of attributes typed (char *) */
        virtual ~Exception();

        //! Copy constructor;
        /*! This constructor copies all attributes, allocates new memory for attributes typed (char *) */
        Exception(const Exception &);

        //! Equality operator;
        /*! This operator '=' copies all attributes, allocates new memory for attributes typed (char *) */
        Exception& operator=(const Exception &);

        //! Constructor(const char * _name);
        /*! This constructor initializes attributes as unknown, except the attributes name defined by the paramter _name. */
        Exception(const char *);

        //! Constructor(const char * _name,const char * _func, const char * _file, int _line);
        /*! This constructor initializes all attributes name, line, func and file. ( except objt)
            The three last parameters (const char * _func, const char * _file, int _line) should be replaced in your code by: EXCEPTION_INFOS
            Example:   throw Exception( "Your exception name" , EXCEPTION_INFOS ); */
        Exception(const char *, const char *, const char *, int);

        //! Method getFile
        /*! This method return a (const char *) result, pointing on the attribute file of the exception  */
        virtual char * getFile() const;
        //! Method getFunction
        /*! This method return a (const char *) result, pointing on the attribute fonction of the exception  */
        virtual char * getFunction() const;
        //! Method getLine
        /*! This method return a (const char *) result, pointing on the attribute line of the exception  */
        virtual int getLine() const;
        //! Method what
        /*! This method return a (const char *) result, pointing on the attribute name (reason) of the exception  */
        virtual char * what() const;
};

#endif


